package com.cn.lyl.servlet.role;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.LawyerRoleModel;
import com.cn.lyl.service.LawyerRoleService;
import com.cn.lyl.service.impl.LawyerRoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/back/role/all")
public class FindAllRoleServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        LawyerRoleService lawyerRoleService = new LawyerRoleServiceImpl();
        List<LawyerRoleModel> all = lawyerRoleService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("roles",all);
        resp.getWriter().print(jsonObject);
    }
}
